package mapper;

import com.yh.javabean.Role;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;
import java.util.concurrent.CountDownLatch;

/**
 * @Auther: Liang
 * @Date: 2024/5/9 - 05 - 09 - 19:04
 * @Description: mapper
 * @version: 1.0
 */
public interface RoleMapper {
    @Select("select ur.uid,r.* from role r,user_role ur where r.rid=ur.rid and ur.uid=#{uid}")
    @ResultMap("r_p")
    Role selectByUid(int uid);


    @Select("select * from role")
    @Results(id = "r_p",value = {
            @Result(id = true,column = "rid",property = "rid"),
            @Result(column = "name",property = "name"),
            @Result(column = "desc",property = "desc"),
            @Result(column = "rid",property = "plist",many = @Many(select="mapper.PermissionMapper.selectByRid",fetchType = FetchType.LAZY))

    })
    List <Role> selectAllRoleAndPermission();
}
